home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 May / PCPlus May 1998=disk A.iso / full / CBUILDER / SAMS / SAMPLES / CHAP08 / CTMAIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-12  |  1.2 KB  |  36 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "CTMain.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TMainForm *MainForm;
  9. //---------------------------------------------------------------------------
  10. __fastcall TMainForm::TMainForm(TComponent* Owner)
  11.   : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TMainForm::FormCreate(TObject *Sender)
  16. {
  17.   char colors[][10] =
  18.       {"Gray", "Blue", "Pink", "Orange", "Mauve"};
  19.   char critters[][10] =
  20.       {"Monkeys",    "Pigs", "Dogs", "Bears", "Tapirs"};
  21.   // fill the listbox with random strings
  22.     randomize();
  23.   char buff[100];
  24.   for (int i=0;i<50;i++) {
  25.     sprintf(buff, "Critter: %s %s",
  26.         colors[random(5)], critters[random(5)]);
  27.     DropDown->Items->Add(buff);
  28.     sprintf(buff, "Critter: %s %s",
  29.         colors[random(5)], critters[random(5)]);
  30.     DropDownList->Items->Add(buff);
  31.     sprintf(buff, "Critter: %s %s",
  32.         colors[random(5)], critters[random(5)]);
  33.     Simple->Items->Add(buff);
  34.   }
  35. }
  36. //---------------------------------------------------------------------